I want the Microsoft Bot Framework Chat Bot to verify my customer using freshservice api.
I have already asked the user for their username and password (corresponding to the : company-domain.freshservice.com) and stored the customers details using state accessor (As shown in the docs provided for SDK4 of Microsoft Bot Framework). Now after obtaining the details, I want the bot to send a http request to freshservice api and authenticate the customer. And display the result of the authentication of the bot to the Chat window (Currently the Bot Framework Emulator). Please help as I am not able to figure out a way to do it.
The Freshservice API is built around CURL, so it's a little difficult to see how to use it in Node. I've taken the first example and converted it for you:
From:
curl -u [email protected]:test -H "Content-Type: application/json" -X GET https://domain.freshservice.com/helpdesk/tickets.json
To:
// Convert to base64
const loginInfo = Buffer.from(`${ username }:${ password }`).toString('base64');
const response = await axios.get(`https://<yourDomain>.freshservice.com/helpdesk/tickets.json`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${ loginInfo }`
}
});
await context.sendActivity(JSON.stringify(response.data, null, 2));
This will result in the full JSON response:
How you choose to display that will be up to you.
npm i axios