Skip to content

Instantly share code, notes, and snippets.

@cianclarke
Created December 18, 2018 15:56
Show Gist options
  • Save cianclarke/ed48aa55d66fbee2afb330571784f8b2 to your computer and use it in GitHub Desktop.
Save cianclarke/ed48aa55d66fbee2afb330571784f8b2 to your computer and use it in GitHub Desktop.
const ServisBotApiSdk = require('@servisbot/servisbot-api-sdk');
const {
Maker,
BaaS
} = ServisBotApiSdk;
// save password
const listTransactions = new BaaS.API({
Alias: 'listTransactions',
Actions: []
});
const listAccounts = new BaaS.API({
Alias: 'listAccounts',
Actions: []
});
listAccounts
/*
* Business Slots
*/
const accountId = new Maker.BusinessSlot({
name: 'accountId',
promptMessages: ['Which account?'],
resolvers: [
new Maker.Resolver({
name: 'byAccountNumber',
defaultResolver: true,
slotType: new Maker.SlotType.Number({
}),
apiDefinition: listAccounts,
})
]
});
/*
* User Intents - these get mapped into a Public AI Engine
*/
const userIntents = [
new Maker.UserIntent({
name: 'listTransactions',
description: 'What were my last transactions',
utterances: [
'What were my last transactions'
],
}),
];
const successMessages = [
new Maker.Response.MarkupResponse(`
<TimelineMessage>
<List selectable="true" title="Here are the transactions">
#foreach( $txn in $transactions )
<Item title=\"$txn.TransactionInformation - $txn.Amount.Currency $txn.Amount.Amount\"/>
#end
</List>
</TimelineMessage>
`)
]
const orchestrator = new Maker.Orchestrator({
businessIntent: new Maker.BusinessIntent({
name: 'transactionHistory',
api: listTransactions,
businessSlots: [accountId],
businessRules: [],
successMessages
}),
responseVoice: new Maker.ResponseVoice.GenericAdvisorResponse(),
promptStrategy: new Maker.PromptStrategy.FlowStrategy(),
userIntents,
// language
});
console.log(JSON.stringify(orchestrator, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment