title: Firebase Cloud Functions - Error with sendToTopic() format
body: <p>My app is a team management system and I want to notify all the players of a certain team if a new event is create via a push notification. There are two types of events that can be created, a <code>Fixture</code> and a <code>Training</code>. I want to have separate notifications for each of them. I am trying to use <code>Firebase Cloud Functions</code> but I keep getting the same error. It says that that the event is triggered but the this error appears. I am quite new to <code>JavaScript</code> so please excuse it if it is a simple syntax error but I can't seem to get it to work. </p>
  
  <p>Index.js</p>
  
  <pre><code>//import firebase functions modules
  const functions = require('firebase-functions');
  //import admin module
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  
  // // Listens for new fixtures being created
  exports.newFixture = functions.database.ref('/Fixture/{currentTeam}/{pushId}').onWrite((change, context) =&gt; {
  
      console.log('new fixture event triggered');
  
      //  Grab the current value of what was written to the Realtime Database.
      var valueObject = change.after.val();
  
    // Create a notification
      const payload = {
          notification: {
              title: "New" + valueObject.type,
              body: "Details:" + " "+ valueObject.date + " " +valueObject.time + " " + "please open app and confirm availability",
              sound: "default"
          },
      };
  
    //Create an options object that contains the time to live for the notification and the priority
      const options = {
          priority: "high",
          timeToLive: 60 * 60 * 24
      };
  
      return admin.messaging().sendToTopic("/topics/{currentTeam}", payload, options);
  });
  
  
  // Listens for new trainings being created
  exports.newTraining = functions.database.ref('/Training/{currentTeam}/{pushId}').onWrite((change, context) =&gt; {
  
    console.log('New training event triggered');
  
    //  Grab the current value of what was written to the Realtime Database.
    var valueObject = change.after.val();
  
  // Create a notification
    const payload = {
        notification: {
            title: "New" + valueObject.type,
            body: "Details:" + " "+ valueObject.date + " " + valueObject.time + " " + "please open app and confirm availability",
            sound: "default"
        },
    };
  
  //Create an options object that contains the time to live for the notification and the priority
    const options = {
        priority: "high",
        timeToLive: 60 * 60 * 24
    };
  
    return admin.messaging().sendToTopic("/topics/{currentTeam}", payload, options);
  });
  </code></pre>
  
  <p>Here is the Error</p>
  
  <pre><code>Error: Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".
      at FirebaseMessagingError.Error (native)
      at FirebaseMessagingError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:39:28)
      at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:85:28)
      at new FirebaseMessagingError (/user_code/node_modules/firebase-admin/lib/utils/error.js:241:16)
      at Messaging.validateTopic (/user_code/node_modules/firebase-admin/lib/messaging/messaging.js:925:19)
      at /user_code/node_modules/firebase-admin/lib/messaging/messaging.js:611:19
      at process._tickDomainCallback (internal/process/next_tick.js:135:7)
  </code></pre>
  
  <p>DB Structure</p>
  
  <p><a href="https://i.stack.imgur.com/vDbBg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vDbBg.png" alt="Training Structure"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ppsTN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ppsTN.png" alt="Fixture Structure"></a></p>
  
  <p>Functions Log</p>
  
  <p><a href="https://i.stack.imgur.com/nRUWG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRUWG.png" alt="FireBase Function LOG"></a></p>
  
  <p>Any help would be greatly appreciated. </p>