How to work with multiple entities in wit.ai

328 views Asked by At

I have just created wit.ai chat bot for pizza booking suppose if I type a sentence: "I want to order Cheese pizza" it has to ask me what is the size. Instead, its again asking me what u want order. Can anyone suggest how to work with multiple entities in wit.ai for below code?

def first_entity_value(entities, entity):
    if entity not in entities:
        return None
    val = entities[entity][0]['value']
    if not val:
        return None
    return val
def handle_message(response):
    entities = response['entities']
    print (entities)
    greetings = first_entity_value(entities, 'greetings')
    order= first_entity_value(entities, 'intent')
    pizza=first_entity_value(entities, 'pizza')
    pizza_type = first_entity_value(entities, 'pizza_type') 
    pizza_size = first_entity_value(entities, 'pizza_size')


    if greetings:
        return 'Hi, How can i help you?'
    elif order:
        return 'What u want to order?' 
    elif pizza:
        return 'u ordered pizza,select type of pizza?'
    elif pizza_type:
        return 'U have ordered cheese,vege or spinach type, Please select size?'    
    elif pizza_size:
        return 'thank you for ordering the pizza'
    else:
        return 'Um .. i dont recognise that request'
1

There are 1 answers

0
Kartik Chugh On

This means that your Wit client is resolving an order entity from the "I want to order Cheese pizza" utterance. I would recommend testing example phrases in your Wit application page first to make sure it's properly trained to your needs.