1

I have an intent that needs a user's phone number in order to search an API, it's basically an intent with a required "phoneNumber" parameter and a webhook for fulfillment. Everything works fine in the best case scenario, but sometimes the user pronounces their number wrong and we don't find any results.

How can I make it so that the intent says something like, "I wasn't able to find anything with that number, can you please repeat it?" or "I wasn't able to search using your number, can you please tell me your name?". Basically, I'd need to keep the user in a loop until we get all the information we need.

I've been playing around with contexts and follow-up intents but they don't seem to work.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
Rob
  • 7,028
  • 15
  • 63
  • 95

1 Answers1

2

Followup Intents are not what you want in this case. They are probably not what you want in most cases.

Contexts can help but may not even be necessary.

Most of all, remember that an Intent captures what the user has said, and not what you are going to do with what they've said or how you reply.

So the simplest answer to how you tell them that you don't have any results is... that your webhook execute code that says there are no results instead of the code that says what the results are.

If the user responds with a phone number, than the Intent you already have created to capture the phone number should be called again.

There are some examples about doing this in this StackOverflow answer, as well as this medium article which was based on the answer and the followup article which shows some details about the Intents.

Now, there are cases where working with a context might make sense. For example, you may wish to use a context to keep count of how many times in a row the Intent has been called since, after a while, it may be safest to stop the conversation or prompt in a different way. You can do this by setting a value in a parameter of the Context and checking or increasing this parameter.

Or it may make sense to use a context to help make sure that the input is treated as a phone number at this specific point in the conversation and not something more arbitrary. You could do this by setting the Input Context for Intents.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • We are capturing the phone number in many different intents, I would need to bring them back to this specific intent. How could I do that? For example, we have a "Track Shipment" intent and a "Speak to a Representative" intent which both ask for phone numbers. If the Track Shipment intent does not have any good results, I could say, "can you repeat your number?" in the fulfillment webhook, but then how could I re-engage this specific intent? – Rob Jan 07 '19 at 02:31
  • Would you be able to clarify how you would set this up? I mapped out the intents according to what you recommended and got 4 intents: Welcome (which adds a phone-number context if it detects caller id), Track Shipment (which is invoked through track shipping utterances), Track Shipment Results and Phone Number. Track Shipment returns either phone-number-needed or track-shipment contexts depending on if it thinks it has a number. This isn't working though :( @Prisoner – Rob Jan 07 '19 at 04:58
  • @Prisoner how can we keep counter? do we need to store it in some DB or Dialogflow provide this feature? – sid8491 Jan 07 '19 at 05:21
  • @Rob - I've clarified my answer a little and pointed to some other answers that address the question, but if you're still confused, it might be best to update your question with concrete examples - showing screen shots of the Intents, for example, and providing what you think the conversational flow should look like. – Prisoner Jan 07 '19 at 16:41
  • 1
    @sid8491 - I've updated the answer to clarify counters a little, but if you're still having problems, asking this as a new question is probably best, since it deviates from what this question is asking. – Prisoner Jan 07 '19 at 16:42
  • @sid8491 - you're welcome, always glad to help where I can. If the answer helps, an upvote is appreciated. – Prisoner Jan 08 '19 at 10:21