0
votes

Let's say I want to book a hotel room from my iOS app which requires logging in with Firebase.

After the user says "book me a room", I want the bot to retrieve the Firebase uid of the user and modify the Firebase database accordignly using his uid.

How should I send the id and retrieve it in my webhook?

Thanks.

2

2 Answers

0
votes

For nodejs...You will need firebase admin sdk for that.. the client side need to post with their firebase tocken id and then the backend gets the token and converts it to uid, and then with their uid and update your database for booking room. For more documentation, link to Firebase admin docs https://firebase.google.com/docs/auth/admin/verify-id-tokens. It is better to ensure verifying users first, or simply for testing development users can post you their uid directly.

0
votes

I am also confused here. But I got a workaround. By sending an event instead of a query, because the event can take parameters. You can put the firebase uid into the parameters. Below is some of my javascript code.

function sendEvent(eventName,params){
$.ajax({
    type: "POST",
    url: baseUrl + "query?v=20150910",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    headers: {
        "Authorization": "Bearer " + accessToken
    },
    data: JSON.stringify({ event:{
        name: "WELCOME",data:{uid:"somethindrandom"}
    }, lang: "zh-CN", sessionId: sessionId }),
    success: function(data) {
        console.log(data);

I send an event to trigger the default welcome Intent by eventName "WELCOME", carrying a uid parameter. Then you can get the uid parameter from #Welcome.uid, and transmit to you webhook. Firebase console screenshot]