Start a conversation at the beginning of a flow using flow ID - dialogflow-cx

Is it possible to use SessionClient or FlowClient to start a session with an agent at the beginning of a specific flow? Dialogflow ES API allows for sending an event, like a Welcome Event. Is there a similar functionality for CX that would take in a flow ID?

If you have your own Custom Integration, you can send a detectIntent request to your agent to trigger a custom event. This lets your agent trigger a page with the custom event and send a response to the user without any user query or input.
Here’s a simple guide to create a custom event:
Inside your flow, select the page you want to add a custom event to
then click the "Event handlers". If the "Event handlers" is not
visible, click the “Add route type” button to add the Event
handlers.
Click on the + sign beside “event handlers” field and
select any event.
Tick the check box beside “Use custom event”.
Add the name of the custom event you want to use.
Add the desired response under “Agent says”.
Click save.
Here’s a sample detectIntent request that triggers the Default welcome intent using Node.js.
Here’s a sample detectIntent request that triggers a custom event using REST API:
Sample URL for detect intent API:
POST
https://dialogflow.googleapis.com/v3beta1/projects/project-id/locations/us/agents/agent-id/sessions/session-id:detectIntent
Make the following replacements for the URL:
project-id: your GCP project ID
agent-id: your agent ID
session-id: your session ID
Sample JSON Request Body should look like this:
{
"queryInput": {
"event": {
"event": "custom-event" // custom event to be triggered
},
"languageCode": "en"
},
"queryParams": {
"timeZone": "America/Los_Angeles"
}
}
You can refer below for more information on:
Sessions
Custom events
You can use Dialogflow CX’s Client Libraries, Rest API, or RPC API to create your own implementation/integration.

Related

How to add button for "Send Transcript" to Directline WebChat

I would like customers to be able to click a button to send themselves a transcript at any point in the conversation. This button should essentially send a message to the bot which would initiate an “email transcript" dialog to prompt for their email and send the transcript. I was able to add a button to the directline webchat client (in my title bar) but I can't figure out how to have it create an activity for the bot. I have a custom store that sends an "inactive" activity but I wasn't able to use this same method to make the button send an activity. Can this be achieved? Or is there another way for customers to get a copy of their transcript?
I have achieved the actual transcript retrieval and emailing in code, initiates by a LUIS intent, I just want to provide an intuitive "always there" option to do this.
The WebChat offers a simple sample that shows you how to send activities programmatically to the bot. In this sample they are creating a separate button with an Event Listener, which will sent your message as a message activity.
If you would like to sent it as an event in the background, you could have a look at this sample, which you could combine with the event listener of the first example.
How to send a message programmatically
How to send welcome event
Note: you need to use the JavaScript WebChat, it is not possible to add this functionality to the iFrame version of the Bot Service.

Is there a way to send the data from the web form to the microsoft botframework web client without opening the web client?

We have a Angular application with .Net core.
When the users type on the input from their web page form field, it will need to be passed to the Microsoft BOT framework.
The response message from the BOT service will need to be displayed back to the Bot Chat client.
Users will review the above response and have the ability to send the received data from Bot Client back to the web page form fields.
I have read about the Web chat client and the Direct Line bot.
I can use Web chat client but I am not sure how to pass the input from my web form to it as I don't want the user to open the web chat to enter the same data again.
If I use the Direct Line Bot, I have control on passing the form input to the Bot service. In this case, I will need to spend time to build the Web client to display and process the messages.
You can do this by utilizing the DirectLine connection instance that you give to the WebChat control when you create it. The connection instance will enable you to both send events into the bot as well as watch for events coming out of the connection. At the same time, since you're sharing the connection with the chat control, the chat control can perform its typical duties of sending and receiving/displaying message contents.
For example, when the user clicks on the submit button on your form, you would utilize the connection object to send an event that contains your payload like so:
Setup DirectLine connection
Create the DirectLine connection at start up and assign it to your WebChat control, but also hold onto the connection object in a variable you can utilize in other places such as the form button click.
const directLineToken = await getDirectLineToken();
const directLineConnection = createDirectLine({ directLineToken });
Form button click logic
In the form button click logic you can now send an event activity that represents your proprietary backchannel event to the bot containing the form details as the payload:
const fancyFormEventPayload = {
fieldA: fieldAFormElement.value,
fieldB: fieldBFormElement.value,
// etc
};
// NOTE: this returns an observable that you can wait on
// to watch for errors or know when it has completed. I'm
// just using fire and forget here for now
directLineConnection.postActivity({
type: "event",
name: "myFancyFormSubmitted",
value: fancyFormEventPayload,
});
Listening for events coming back
Now the bot might respond with some message activities which the WebChat would then display, but it could also send back an event activity that contains the updated form payload which you could watch for and grab to populate the form with the updated values if they say "yes" for that.
// The connection exposes the stream of incoming activities via Rx, so
// we create filtered subscription that will process only the activity
// we're interested in and update the form fields in response to that
directLineConnection.activity$
.filter(activity => activity.type === 'event' && activity.name === 'myFancyFormUpdate')
.subscribe(activity =>
{
const myFancyFormPayload = activity.value;
fieldAFormElement.value = myFancyFormPayload.fieldA;
fieldBFormElement.value = myFancyFormPayload.fieldB;
// etc
});

Hot to enable Cloud Elements Microsoft Graph Calendar webhooks for all calendars?

By default, when I integrate my Microsoft account with cloud elements:
https://developers.cloud-elements.com/docs/elements/microsoftgraph/
I only get notifications for my default calendar. But, in fact, I have like 5+ calendars. I want to get notifications about changes in all of them.
For now, I can only think of making a new end-point that accepts calendar ID and then I invoke this endpoint with the result of invocation:
GET /calendars
But, this looks like a hack. Is there a better solution to listen to all the calendars that I have using Cloud Elements?
According to your description, I assume you want to get the notifications for your calendar when the calendar changed.
We can use the subscription endpoint to get the notifications. For more detail about this endpoint, we can refer to this document
In the Cloud Elements UI, if you select the instance and click the api docs you will see four sections "information", "setup", "resources", and "models". Select resources and you will see one that has POST /webhooks
This is the call the Cloud Elements sends on webhook provision. If you want to change the body of the webhook go to the PreRequest Hook where you will see javascript that is creating a post body that will be sent to Microsoft.
By default the body you see in the javascript looks like:
var body={
"changeType": "created,updated,deleted",
"notificationUrl": "{webhookCallbackUrl}",
"resource": "/me/events",
"expirationDateTime": newDate
}
If you want to change what resources you get notification for you can do so in this body and using the documentation that was provided in the previous answer

Can we pass custom values using square connect and have it returned back in webhook notification

I am looking for information on how to pass a custom variable (transaction_logID) to the square API and then have it returned back to me on the webhooks notification URL response.
How can i specifically link a "charge" event with a "notification" event so that I can update my personal SQL record with the transaction result? (Approved, Declined etc)
Thanks for your help.
Unfortunately passing in custom data and getting it back in a webhook isn't possible.
Depending on what exactly you want to link your notification to, you can look up the ID from the webhook in the v1 payments endpoints.

Trigger script on Google calendar event

I want to trigger some script when new calendar event is created in Google Calendar (say calling some rest API that enters event information to my database). I do not want any kind of UI that triggers the script. Is it possible to achieve this using Google gadget since I do not want any UI? I would really appreciate the help as I am new to Google API.
Thanks a lot
Shubhra
Calendar API has something like notifications. See this link: Push Notifications. From documentation:
The Google Calendar API provides push notifications that let you watch
for changes to resources. You can use this feature to improve the
performance of your application. It allows you to eliminate the extra
network and compute costs involved with polling resources to determine
if they have changed. Whenever a watched resource changes, the Google
Calendar API notifies your application.
Google Calendar API (relevant docs) provides a watch endpoint that allows you to specify a webhook upon certain events.
To set up the webhook, you can call the Calendar API endpoint a POST request to https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch with the body
{
"id": string
"type": string,
"address": string
}
The "address" field tells Calendar what endpoint to call when there is a new Calendar event. You'll need to create and host this endpoint yourself.
Another option is to use a service like Zapier, which has fantastic integrations for Google Calendar and makes setting up a listener (i.e. a trigger) and corresponding action very simple.

Resources